<?php
	if($_SERVER["REQUEST_METHOD"]=="POST") {
		$title		= strip_tags($_POST['title']);
		$name		= strip_tags($_POST['name']);
		$telephone	= strip_tags($_POST['telephone']);
		$email		= strip_tags($_POST['email']);
		$detail		= strip_tags($_POST['detail']);
		$ip			= getUserIP();

		$sql ="INSERT INTO `tbl_contact` (`contact_id`, `title`, `name`, `telephone`, `email`, `detail`, `ssid`, `ip`, `date`, `status`) VALUES (NULL, '$title', '$name', '$telephone', '$email', '$detail', '$ss_id', '$ip', NOW(), '0');";
		mysql_query($sql);
		echo '<script type="text/javascript"> alert("ได้ทำการส่งข้อมูลเรียบร้อยแล้วค่ะ");window.location.href=""</script>';
		exit;
	}

	$sql = "SELECT `title` , `telephone` FROM `tbl_locations` WHERE `telephone` != '' ORDER BY `location_id` ASC";
	$query = mysql_query($sql) or die($sql);
	$tp->Block('locations');
	while($result = mysql_fetch_assoc($query)) {
		$contact_title		= $result['title'];
		$contact_telephone	= $result['telephone'];
		$tp->Apply();
	}
	mysql_free_result($query);
?>